package com.jingjiu.homeservicesbiz.service;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingjiu.homeservicesapi.domain.HouseService;
import com.jingjiu.homeservicesbiz.mapper.HouseServiceMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



/**
 * 家政服务：记录各种家政服务的基本信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-04-16
 */
@Service
public class HouseServiceServiceImpl extends ServiceImpl<HouseServiceMapper, HouseService>
{
    @Autowired
    private HouseServiceMapper houseServiceMapper;



    public Page<HouseService> selectPage(Page<HouseService> page, HouseService houseService) {
        LambdaQueryWrapper<HouseService> queryWrapper = new LambdaQueryWrapper<>();

        // 模糊查询服务名称
        if (StringUtils.isNotBlank(houseService.getServiceName())) {
            queryWrapper.like(HouseService::getServiceName, houseService.getServiceName());
        }

        // 根据价格筛选（如果需要可加上价格区间判断）
        if (houseService.getPrice() != null) {
            queryWrapper.eq(HouseService::getPrice, houseService.getPrice());
        }

        // 按照 ID 倒序排（也可以用创建时间字段）
        queryWrapper.orderByDesc(HouseService::getId);


        return this.page(page, queryWrapper);
    }

    /**
     * 查询家政服务：记录各种家政服务的基本信息
     * 
     * @param id 家政服务：记录各种家政服务的基本信息主键
     * @return 家政服务：记录各种家政服务的基本信息
     */

    public HouseService selectHouseServiceById(Long id)
    {
        return houseServiceMapper.selectHouseServiceById(id);
    }

    /**
     * 查询家政服务：记录各种家政服务的基本信息列表
     * 
     * @param houseService 家政服务：记录各种家政服务的基本信息
     * @return 家政服务：记录各种家政服务的基本信息
     */

    public List<HouseService> selectHouseServiceList(HouseService houseService)
    {
        return houseServiceMapper.selectHouseServiceList(houseService);
    }

    /**
     * 新增家政服务：记录各种家政服务的基本信息
     * 
     * @param houseService 家政服务：记录各种家政服务的基本信息
     * @return 结果
     */

    public int insertHouseService(HouseService houseService)
    {
        return houseServiceMapper.insertHouseService(houseService);
    }

    /**
     * 修改家政服务：记录各种家政服务的基本信息
     * 
     * @param houseService 家政服务：记录各种家政服务的基本信息
     * @return 结果
     */

    public int updateHouseService(HouseService houseService)
    {
        return houseServiceMapper.updateHouseService(houseService);
    }



    /**
     * 删除家政服务：记录各种家政服务的基本信息信息
     * 
     * @param id 家政服务：记录各种家政服务的基本信息主键
     * @return 结果
     */

    public int deleteHouseServiceById(Long id)
    {
        return houseServiceMapper.deleteHouseServiceById(id);
    }
}
